﻿//#include <iostream>
//#include "myComplexNumber.h"
//#define PI 3.14159265354
//using namespace std;
//
//int main()
//{
//	//15, 32, 9, 222, 18, 151, 5, 7, 56, 233, 56, 121, 235, 89, 98, 111
//	int testArray[4][4] = { {15, 32, 9, 222},{18, 151, 5, 7},{56, 233, 56, 121} ,{235, 89, 98, 111} };
//	myComplexNumber testOutcome[4][4];
//	for (int u = 0; u < 4; u++)
//	{
//		for (int v = 0; v < 4; v++)
//		{
//			for (int x = 0; x < 4; x++)
//			{
//				for (int y = 0; y < 4; y++)
//				{
//					myComplexNumber ux(cos(-2 * PI * u * x / 4), sin(-2 * PI * u * x / 4));
//					myComplexNumber vy(cos(-2 * PI * v * y / 4), sin(-2 * PI * v * y / 4));
//					testOutcome[u][v].real += testArray[x][y] * (ux * vy).real;
//					testOutcome[u][v].img += testArray[x][y] * (ux * vy).img;
//				}
//			}
//			cout << "u:" << u << " v:" << v << "----real:" << testOutcome[u][v].real << "  img:" << testOutcome[u][v].img << endl;
//		}
//	}
//
//	system("pause");
//	return 0;
//}



#include <iostream>
#include "ThreadPool.h"
#include <windows.h>
void multiply(const int a, const int b)
{
	Sleep(2000);
	int res = a * b;
	std::cout<< "multiply " << a << " * " << b << " = " << res << std::endl;
}

void multiply_output(int & out, const int a, const int b)
{
	Sleep(2000);
	out = a * b;
	std::cout << "multiply_outout " << a << " * " << b << " = " << out << std::endl;
}

int multiply_return(const int a, const int b)
{
	Sleep(2000);
	int out = a * b;
	std::cout << "multiply_return " << a << " * " << b << " = " << out << std::endl;
	return out;
}

void example()
{
	ThreadPool pool(3);

	for (int i = 1; i <= 3; ++i)
	{
		for (int j = 1; j <= 10; ++j)
		{
			pool.submit(multiply, i, j);
		}
	}

	int output_ref;
	auto future1 = pool.submit(multiply_output, std::ref(output_ref), 5, 6);
	future1.get();
	std::cout << "Last operation result is equals to " << output_ref << std::endl;

	auto future2 = pool.submit(multiply_return, 4, 2);
	int res = future2.get();
	std::cout << "Last operation result is equals to " << res << std::endl;
}

int main()
{
	example();
	system("pause");
	return 0;
}